package cn.itsource.controller.app;

import cn.itsource.domain.DriverAuthMaterial;
import cn.itsource.pojo.ro.GetDriverStatusRo;
import cn.itsource.pojo.ro.SaveDriverAuthMaterialRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IDriverAuthMaterialService;
import cn.itsource.service.IDriverSettingService;
import cn.itsource.service.IDriverSummaryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "司机实名资料",description = "司机实名资料")
@RestController
@RequestMapping("/app/driverAuthMaterial")
public class AppDriverAuthController {

    @Autowired
    public IDriverAuthMaterialService driverAuthMaterialService;

    @Autowired
    private IDriverSummaryService driverSummaryService;
    @Autowired
    private IDriverSettingService driverSettingService;

    @Operation(summary = "审批认证", description = "审批认证")
    @Parameter(name = "driverAuthMaterial", description = "审批认证", required = true)
    @PostMapping("/audit")
    public JSONResult audit(@RequestBody @Valid GetDriverStatusRo driverStatusRo) {
        driverAuthMaterialService.audit(driverStatusRo);
        return JSONResult.success();
    }

    @Operation(summary = "撤销审批认证", description = "撤销审批认证")
    @Parameter(name = "driverAuthMaterial", description = "撤销审批认证", required = true)
    @PostMapping("/cancel")
    public JSONResult cancel(@RequestBody @Valid GetDriverStatusRo driverStatusRo) {
        driverAuthMaterialService.cancel(driverStatusRo);
        return JSONResult.success();
    }

    @Operation(summary = "获取司机实名认证状态", description = "获取司机实名认证状态")
    @Parameter(name = "driverAuthMaterial", description = "获取司机实名认证状态", required = true)
    @GetMapping("/getDriverStatus")
    public JSONResult getDriverStatus() {
        return JSONResult.success(driverAuthMaterialService.getDriverStatus());
    }
    @Operation(summary = "获取司机原料状态", description = "获取司机原料状态")
    @GetMapping("/getDriverMaterial")
    public JSONResult getDriverMaterial() {
        return JSONResult.success(driverSummaryService.getDriverMaterial());
    }
    @Operation(summary = "保存认证信息", description = "保存认证信息")
    @Parameter(name = "driverAuthMaterial", description = "保存认证信息", required = true)
    @PostMapping("/save")
    public JSONResult save(@RequestBody @Valid SaveDriverAuthMaterialRo driverAuthMaterialRo) {
        driverAuthMaterialService.save(driverAuthMaterialRo);
        return JSONResult.success();
    }
}